package logicals

import (
	"easyblog/models"
	"easyblog/utils/db"
	"easyblog/utils/errmsg"
)

type UserLogical struct {}

var DefaultUser = UserLogical{}

// 登录验证
func (this *UserLogical) CheckLogin(username string, password string) int {
	var user models.User
	db.Db.Where("username = ?", username).First(&user)
	if user.ID == 0 {
		return errmsg.ERROR_USERNAME_NOT_EXIST //用户不存在
	}
	if password != user.Password {
		return errmsg.ERROR_PASSWORD_WRONG //密码错误
	}

	return errmsg.SUCCSE
}